<template>
  <div>
    <el-row justify="center" type="flex" style="padding-top:40px">
      <el-col :span="8">
        <div>
          Manager Id:
          <el-input
            v-model="branchInfo.manager_id"
          >
          </el-input>
        </div>
        <div>
          Manager Telephone:
          <el-input
            v-model="branchInfo.manager_telephone"
          >
          </el-input>
        </div>

        <p>Address:</p>
      </el-col>
    </el-row>
    <el-row type="flex" justify="center" align="center">

      <el-col :span="8">
        <div>

          <el-select v-model="add1" placeholder="请选择">
            <el-option
              v-for="(item,i) in Addr1"
              :key="i"
              :label="item"
              :value="i">
            </el-option>
          </el-select>
          <el-select v-model="branchInfo.add2" placeholder="请选择">
            <el-option
              v-for="(item,i) in Addr2"
              :key="i"
              :label="item.name"
              :value="i">
            </el-option>
          </el-select>
          <el-select v-if="!branchInfo.add2" placeholder="请选择">
          </el-select>
          <el-select v-else="branchInfo.add2" v-model="branchInfo.add3" placeholder="请选择">
            <el-option
              v-for="(item,i) in Addr2[branchInfo.add2].list"
              :key="i"
              :label="item"
              :value="i">
            </el-option>
          </el-select>
          <el-input
            v-model="branchInfo.add4"
          >
          </el-input>
        </div>
      </el-col>


    </el-row>
    <el-row type="flex" justify="center" style="margin-top:200px">
      <el-button type="warning">Change</el-button>
    </el-row>
  </div>

</template>

<script>
    export default {
        name: "GDFunctionBranchInfo",
      data(){
          return{
            branchInfo: {},
            add1: 0,
            Addr1: [],
            Addr2: []
          }
      },
      created() {
        this.Addr1 = this.api.address1;
        this.Addr2 = this.api.address2;
        const info=this.api.branchList[this.$store.state.branch];
        const add2=(()=>{
          let i=0;
          for (const address2Element of this.api.address2) {
            if(address2Element.name===info.address.add2) return i;
            i++;
          }
        })();
        this.branchInfo={
          manager_id:info.manager.id,
          manager_telephone:info.manager.telephone,
          add2:add2,
          add3:this.api.address2[add2].list.indexOf(info.address.add3),
          add4:info.add4
        };
      },
    }
</script>

<style scoped>

</style>
